package com.parenting.controller;


import com.parenting.oauth2.config.AuthUtil;
import com.parenting.request.ReplyRequest;
import com.parenting.response.ReplyListResponse;
import com.parenting.service.ReplyService;
import com.parenting.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 回复表 前端控制器
 * </p>
 *
 * @author 烟台业达-王世玺
 * @since 2021-09-27
 */
@RestController
@RequestMapping("/reply")
@Api(tags = "评价回复")
public class ReplyController {

    @Autowired
    private ReplyService replyService;

    @ApiOperation("评价回复查询")
    @ApiImplicitParam(name = "evaluationId", value = "主题ID", required = true)
    @GetMapping("list/{evaluationId}")
    public Result<List<ReplyListResponse>> getReplyListResponse(@PathVariable("evaluationId") String evaluationId){
        List<ReplyListResponse> replyListResponse = replyService.getReplyListResponse(evaluationId);
        return Result.buildSuccess(replyListResponse);
    }


    @ApiOperation("回复评论")
    @PostMapping("add")
    public Result addReply(@RequestBody  ReplyRequest replyRequest){
        replyService.addReply(replyRequest, AuthUtil.getUserInfo());
        return Result.buildSuccess();
    }
}

